#!/usr/bin/python
# -*- coding: utf-8 -*-
import hashlib
from conf.config import appSecret,systemCode,appKey,notifyUrl
from util.log_util import get_logger
from util.time_util import utc_to_local
import uuid
import json
logger = get_logger()

def signutils(appSecret, params):
    keys = list(params.keys())
    list.sort(keys)
    temp = ""
    for k in keys:
        v = params.get(k)
        if isinstance(v, list):
            continue
        temp = temp + str(k) + "=" + str(v) + "&"
    temp = temp + "appSecret=" + appSecret
    logger.info(temp)
    # MD5加密
    md = hashlib.md5()
    md.update(temp.encode("utf-8"))
    hex_res = md.hexdigest()
    return hex_res.upper()


if __name__ == "__main__":
    params = {
        "timestamp": 1611570390,
        "systemCode": systemCode,
        "messageType": 4,
        "messageCodeDTOList": [1,2],
        "appKey": appKey,
        "notifyUrl": notifyUrl
    }
    signutils(appSecret, params)
